package ren.kane.asdppp.schedule;

import java.time.DayOfWeek;
import java.time.LocalDate;

/**
 * @author renrk(1275) on 2019-04-12 10:25 AM
 **/
public class WeeklySchedule implements PaymentSchedule {

    @Override
    public boolean isPayDate(LocalDate payDate) {
        return isFriday(payDate);
    }

    @Override
    public LocalDate getPayPeriodStartDate(LocalDate payPeriodEndDate) {
        return payPeriodEndDate.minusDays(5);
    }

    private boolean isFriday(LocalDate payDate) {
        return payDate.getDayOfWeek().equals(DayOfWeek.FRIDAY);
    }
}
